BlinkerButton Button1("btn_led");   //LED开关按键模块
BlinkerNumber Number1("num_count"); //数字显示模块
BlinkerNumber Number2("num_temp");  //数字显示模块
BlinkerNumber Number3("num_humi");  //数字显示模块

/**
  * @brief  手机发送blinker如果未绑定的组件被触发
  *         则会执行该回调函数其中内容
  * @param  None
  * @retval None
  */
void unknow_module(const String &data)
{
    static int counter = 0;

    BLINKER_LOG("Blinker readString: ", data);
    //Blinker.vibrate(200);
    if (isright)
        Number1.icon("fas fa-check-circle");
    else
        Number1.icon("fas fa-exclamation-circle");
    Number1.print(counter++);
}

/**
  * @brief  按键button1的回调函数
  * @param  state:按钮状态
  * @retval None
  */
void button1_callback(const String &state)
{
    BLINKER_LOG("get button state: ", state);

    if (state == BLINKER_CMD_ON)
    {
        BLINKER_LOG("Toggle on!");

        //更改手机APP按钮的样式
        Button1.color("#FFCC00"); //开了灯 亮色
        Button1.text("关灯");     //显示文字"关灯"
        Button1.print("on");      //按钮为开

        digitalWrite(LED_BUILTIN, LOW);
        wsState = true;
        light = 100;
    }
    else if (state == BLINKER_CMD_OFF)
    {
        BLINKER_LOG("Toggle off!");

        Button1.color("#1E1E1E");
        Button1.text("开灯");
        Button1.print("off");

        digitalWrite(LED_BUILTIN, HIGH);
        wsState = false;
        light = 0;
    }
}

/**
  * @brief  数据上传回调 Blinker会1分钟调用1次
  * @param  None
  * @retval None
  */
void dataStorage(void)
{
    BLINKER_LOG("Upload chart data");
    Blinker.dataStorage("cha_temp", temp_read); //储存信息到缓存
    Blinker.dataStorage("cha_humi", humi_read);
}
